home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / telecomm / sticpsrc.lzh / SOURCE.ARC / ECVEC.ASM < prev    next >
Assembly Source File  |  1989-07-25  |  2KB  |  90 lines

  1.     name    ecvec
  2.     include    pmacros.h
  3.  
  4.     inthandler    ec, 0
  5.     inthandler    ec, 1
  6.     inthandler    ec, 2
  7.  
  8. ; fast buffer I/O routines -- used by 3-COM Ethernet controller
  9.  
  10. ; outbuf - put a buffer to an output port
  11.     procdef outbuf,<<oport,word>,<obuf,ptr>,<ocnt,word>>
  12.     pushf
  13.     push    si
  14.     pushds
  15.     mov    dx,oport
  16.     mov    cx,ocnt
  17.     ldptr    si,obuf,ds    ; ds:si = obuf
  18.     cld
  19.  
  20. ; If buffer doesn't begin on a word boundary, send the first byte
  21.     test    si,1    ; (buf & 1) ?
  22.     jz    obufeven ; no
  23.     lodsb        ; al = *si++;
  24.     out    dx,al    ; out(dx,al);
  25.     dec    cx    ; cx--;
  26.     mov    ocnt,cx    ; save for later test
  27. obufeven:
  28.     shr    cx,1    ; cx = cnt >> 1; (convert to word count)
  29. ; Do the bulk of the buffer, a word at a time
  30.     jcxz    onobuf    ; if(cx != 0){
  31. xb:    lodsw        ; do { ax = *si++; (si is word pointer)
  32.     out    dx,al    ; out(dx,lowbyte(ax));
  33.     mov    al,ah
  34.     out    dx,al    ; out(dx,hibyte(ax));
  35.     loop    xb    ; } while(--cx != 0); }
  36. ; now check for odd trailing byte
  37. onobuf:    mov    cx,ocnt
  38.     test    cx,1
  39.     jz    ocnteven
  40.     lodsb        ; al = *si++;
  41.     out    dx,al
  42. ocnteven:
  43.     popds
  44.     pop    si
  45.     popf
  46.     pret
  47.     pend    outbuf
  48.  
  49. ; inbuf - get a buffer from an input port
  50.     procdef inbuf,<<iport,word>,<ibuf,ptr>,<icnt,word>>
  51.     pushf
  52.     push    di
  53.     pushes
  54.     mov    dx,iport
  55.     mov    cx,icnt
  56.     ldptr    di,ibuf,es    ; es:di = ibuf (es already set in small model)
  57.     cld
  58.  
  59. ; If buffer doesn't begin on a word boundary, get the first byte
  60.     test    di,1    ; if(buf & 1){
  61.     jz    ibufeven ;
  62.     in    al,dx    ; al = in(dx);
  63.     stosb        ; *di++ = al
  64.     dec    cx    ; cx--;
  65.     mov    icnt,cx    ; icnt = cx; } save for later test
  66. ibufeven:
  67.     shr    cx,1    ; cx = cnt >> 1; (convert to word count)
  68. ; Do the bulk of the buffer, a word at a time
  69.     jcxz    inobuf    ; if(cx != 0){
  70. rb:    in    al,dx    ; do { al = in(dx);
  71.     mov    ah,al
  72.     in    al,dx    ; ah = in(dx);
  73.     xchg    al,ah
  74.     stosw        ; *si++ = ax; (di is word pointer)
  75.     loop    rb    ; } while(--cx != 0);
  76. ; now check for odd trailing byte
  77. inobuf:    mov    cx,icnt
  78.     test    cx,1
  79.     jz    icnteven
  80.     in    al,dx
  81.     stosb        ; *di++ = al
  82. icnteven:
  83.     popes
  84.     pop    di
  85.     popf
  86.     pret
  87.     pend    inbuf
  88.  
  89.     end
  90.